<?php

class Pages extends CI_Controller // this controller inherits from CI_Controller
{

	public function __construct()
    {
        parent::__construct();
    }
	
	/*
	public function __construct()
    {
        if ($this->is_logged_in())
        {
            // redirect to home
        }
    }
	*/
	
	//public function view($page = 'home')
	public function view($page = '')
	{
		// required
		$this->load->helper('html');
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		$this->load->library('session');
		//
		$age_validation = $this->session->userdata('age_validation');
		//
		if ($age_validation)
		{
			/**/
			if ( ! file_exists('application/views/pages/'.$page.'.php'))
			{
				// Whoops, we don't have a page for that!
				show_404();
			}
			
			
			$data['title'] = ucfirst($page); // Capitalize the first letter
			$this->load->view('templates/header', $data);
			$this->load->view('pages/'.$page, $data);
			$this->load->view('templates/footer', $data);
		}
		else
		{
			$data['title'] = ucfirst($page); // Capitalize the first letter
			$this->load->view('templates/header_blank', $data);
			$this->load->view('pages/age', $data);
			$this->load->view('templates/footer_blank', $data);
		}
	}
}

